package com.zyw.teacher.login.entity;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * @Description: 用户信息实体
 * @Author: zyw
 * @Date: 2018/12/10
 */
@Table(name = "t_user")
public class User implements UserDetails {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long id;
    public String loginName;
    public String passwrd;
    public String name;
    public String mobile;
    public Long createId;
    public Date createTime;
    public Long modifyId;
    public Date modifyTime;
    public boolean isProperty;
    public List<Role> roles;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getPasswrd() {
        return passwrd;
    }

    public void setPasswrd(String passwrd) {
        this.passwrd = passwrd;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public Long getCreateId() {
        return createId;
    }

    public void setCreateId(Long createId) {
        this.createId = createId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Long getModifyId() {
        return modifyId;
    }

    public void setModifyId(Long modifyId) {
        this.modifyId = modifyId;
    }

    public Date getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Date modifyTime) {
        this.modifyTime = modifyTime;
    }

    public boolean isProperty() {
        return isProperty;
    }

    public void setProperty(boolean property) {
        isProperty = property;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return roles;
    }

    @Override
    public String getPassword() {
        return passwrd;
    }

    @Override
    public String getUsername() {
        return loginName;
    }

    /**
     * 如果能正常使用返回true，如果过期了返回false
     * @Author: zyw
     * @result
     */
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    /**
     *  如果没有锁定则返回true 如果锁定了返回false
     * @Author: zyw
     * @result
     */
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    /**
     * 如果用户的凭证有效返回true 否则返回false
     * @Author: zyw
     * @result 
     */
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    /**
     * 如果用户有效 返回true 否则返回 false
     * @Author: zyw
     * @result 
     */
    @Override
    public boolean isEnabled() {
        return true;
    }
}
